/******************************************
 * GUIZ.h - header for the GUIZ class
 *
 * class for a GUI.
 *
 * Author: Jeremy Zito
 * Date:   1/10/07
 ******************************************/
#ifndef GUIZ_H
#define GUIZ_H

#include <windows.h>
#include "gl.h"
#include "glu.h"
#include <fstream>
#include <vector>
#include <map>
#include <string>

#include "window.h"


//define button states if there is no glut library
#ifndef GLUT_LEFT_BUTTON
#define GLUT_LEFT_BUTTON		0
#endif

#ifndef GLUT_MIDDLE_BUTTON
#define GLUT_MIDDLE_BUTTON		1
#endif

#ifndef GLUT_RIGHT_BUTTON
#define GLUT_RIGHT_BUTTON		2
#endif

#ifndef GLUT_DOWN
#define GLUT_DOWN			0
#endif

#ifndef GLUT_UP
#define GLUT_UP				1
#endif



//define the GUIZ class
class GUIZ {
            
      private:
              
              //** DEFINE THE MAIN STRUCTS USED IN GUIZ **//
              
              //information for a window's skin textures
              struct image{
                     unsigned long sizeX;
                     unsigned long sizeY;
                     bool alpha;
                     GLuint tt;
                     char name[64];
              };
                                                                                              
              
              
              //** DEFINE VECTORS AND MAPS **//
              
              //a vector to keep image data
              typedef std::vector<image> images;     
              
              
              
              //vector to keep track of loaded skins
              std::vector<std::string> skin_names;
              
              
              //keep track of all image groups from skin files
              //indexed by the skin's index number
              std::vector<images> skins;
              
              
              //create a vector to keep track of window render order
              //(which has greatest degree of focus)
              std::vector<int> focus;
              
              
              
              
              //** DEFINE PRIVATE FUNCTIONS **//
              
              //function to load the skin for the window
              //made up of targa files for transparent effects
              void load_skin(int, char* filename);
              
              //function to draw text in OpneGL
              //sent the text and position of the text
              void draw_text(char* text, int, int, float);
              
              //function to get the image id of an image
              //with the supplied name in the specified skin
              //returns -1 if image not found
              int get_image_id(int, char*);
              
              
              
              //** DEFINE PRIVATE VARIABLES **//
              
              //keep track of old x and y values for mouse
              int old_x, old_y;
              
              //number to keep track of the font texture
              GLuint font_t;
              
              //the selected window
              int selected;

			  //a selected textbox
			  int current_tb;
              
  
			  //a selected listbox
              int current_lb;

			  float proj_mat[16];
			  int   viewport[4];
			  float modl_mat[16];
              
              
              
              
      public:
              
              
             typedef window* window_ptr; 
              
             
             //** DEFINE PUBLIC FUNCTIONS **//
             
             //function to initialize the gui class
              void init();
             
             
              //creates a new window, returns a pointer to the window structure
              window_ptr create_window(char* name, char* skinfile, int x, int y, int w, int h);
              
              
              //creates a new window, returns a pointer to the window.
              //does not use a skin (invisible window, used as container
              //for "windowless" objects).
              window_ptr create_window(char* name, int x, int y, int w, int h);
              
              
              //check for click events - takes the mouse button
              //pressed (GLUT_LEFT_BUTTON or GLUT_RIGHT_BUTTON)
              //and the state of the button (GLUT_UP or GLUT_DOWN).
              //the x and y position of the mouse is also needed
              //to determine button or window clicked
              int check_click_event(int button, int state,
                                     int x, int y);
              
              
              //update any window or sub-object if it's being dragged                       
              void check_drag_event(int x, int y);


			  //check key events - takes the key pressed and
			  //checks if any text boxes are taking input
			  //returns true if test was entered into
			  //a text box and false otherwise.
			  bool check_key_event(int key);
              
              
              //draws all visable windows
              void draw_GUI();
              
              
              
              //** DEFINE PUBLIC VARABLES **//
              
              //window that currently has focus
              int cur_focus_window;
              
              //keep track of all the windows on the screen
              std::vector<window> windows;
                 
             
};

typedef window GUIZ_window;

#endif /* GUIZ_H */

